package com.happyrecyclingstation.controller.jobseeker;

import com.happyrecyclingstation.dto.ResumeDto;
import com.happyrecyclingstation.service.ResumeService;
import com.happyrecyclingstation.utils.Result;
import com.happyrecyclingstation.vo.ResumeVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 求职者
 */
@Slf4j
@RestController("jobSeekerResumeController")
@RequestMapping("/jobSeeker/resumes")
public class ResumeController {

    @Autowired
    private ResumeService resumeService;

    /**
     * 获取简历
     * @return
     */
    @GetMapping
    public Result getResume(){
        ResumeVO resumeVo = resumeService.getResumeByUserId();
        return Result.success(resumeVo);
    }

    /**
     * 保存简历
     * @param resumeDto
     * @return
     */
    @PostMapping
    public Result saveResume(@RequestBody ResumeDto resumeDto){
        log.info("保存简历: {}", resumeDto);
        resumeService.saveResume(resumeDto);
        return Result.success();
    }

    /**
     * 投递简历
     * @param companyId
     * @param positionId
     * @return
     */
    @PostMapping("/{companyId}/{positionId}")
    public Result applyPosition(@PathVariable("companyId") Integer companyId,
                               @PathVariable("positionId") Integer positionId){
        log.info("投递简历：companyId:{},positionId:{}", companyId, positionId);
        Result result = resumeService.sendResume(companyId, positionId);
        return result;
    }
}
